package main.java.FSMDE.models;

import java.util.UUID;

import main.java.ERMDE.infrastructure.Func;
import main.java.ERMDE.infrastructure.IterableExtensions;
import main.java.ERMDE.models.ModelCollection;


public class InterfaceCollection extends ModelCollection<Interface> {

	public InterfaceCollection() {
		super();
	}

	public boolean add(String interfaceName, InterfaceType interfaceType,
			InterfaceGraphType interfaceGraphType) {
		return this.add(new Interface(interfaceName, interfaceType,
				interfaceGraphType));
	}

	public boolean add(Interface interface1) {
		if (this.get(interface1.getName()) == null) {
			this.items.add(interface1);
		}
		return false;
	}

	public Interface get(UUID id) {
		return IterableExtensions.firstOrDefault(this.items,
				new Func<Interface, String, Boolean>() {
					@Override
					public Boolean execute(Interface item, String id) {
						return item.getId().toString().equals(id);
					}
				}, id.toString());
	}

	@Override
	protected Interface createItemInstance(String itemName) {
		return new Interface(itemName);
	}

	public void remove(Interface interface1) {
		this.items.remove(interface1);
	}
}
